package com.hd.crdao.base;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;

import com.hd.crdao.utils.ActivityManagerUtils;
import com.hd.crdao.view.ExpandHeadView;

import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 *
 *@author Programming
 *@date 2017/5/23 0023
 */

public abstract class BaseSecondActivity extends Activity {


    private Unbinder mUnbinder;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        ActivityManagerUtils.addActivity(this);
        super.onCreate(savedInstanceState);
        setContentView(setContentView());
        mUnbinder = ButterKnife.bind(this);
        initHeadView(setExpandHeadView());
        initView();
    }

    protected abstract int setContentView();

    protected abstract ExpandHeadView setExpandHeadView();

    public void initHeadView(ExpandHeadView headView) {
        if (headView != null) {
            headView.getLeftArrowLL().setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    onBackPressed();
                }
            });
        }
    }

    protected abstract void initView();

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mUnbinder.unbind();
        ActivityManagerUtils.removeActivity(this);
    }
}
